import Vue from 'vue'

const state = {
    token: null,
    username: null,
    isLogin: false
}

const actions = {
    login({state}, {username, password}) {
        Vue.axios.post('/login', {
            username: username,
            password: password
        }).then(response => {
            state.token = response.data.token
        }).catch( err => {
            console.log(err)
        })
    }
}

export default {
    namespaced: true,
    state,
    actions
}